<?php

namespace App\Admin\Controllers;

use App\Http\Controllers\Controller;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Layout\Column;
use Encore\Admin\Layout\Content;
use Encore\Admin\Layout\Row;
use Encore\Admin\Widgets\Box;
use Encore\Admin\Widgets\Chart\Bar;
use Encore\Admin\Widgets\Chart\Doughnut;
use Encore\Admin\Widgets\Chart\Line;
use Encore\Admin\Widgets\Chart\Pie;
use Encore\Admin\Widgets\Chart\PolarArea;
use Encore\Admin\Widgets\Chart\Radar;
use Encore\Admin\Widgets\Collapse;
use Encore\Admin\Widgets\InfoBox;
use Encore\Admin\Widgets\Tab;
use Encore\Admin\Widgets\Table;
use DB;

class HomeController extends Controller
{
    public function index()
    {
        return Admin::content(function (Content $content) {

            $content->header('vtmer后台管理系统');
            $content->description('就很容易看到所有东西');

            $content->row(function ($row) {
                //$time = Carbon::now();
                //dd($time);
                /*$today = strtotime(date("Y-m-d"),time());
                $today_time = date("Y-m-d H:i:s",$today);
                $nextDay_time = date("Y-m-d H:i:s", $today+60*60*24);
                $new_users_counts = DB::table('users')->where([['created_at', '>', $today_time], ['created_at', '<', $nextDay_time]])->count();*/
                $apply_count = DB::table('applications')->count();
                //$post_counts = DB::table('posts')->count();
                //$post_comments = DB::table('comments_in_posts')->count();
                $row->column(5, new InfoBox('报名人数', 'users', 'aqua', '/admin/users', $apply_count));
                //$row->column(4, new InfoBox('帖子数量', 'file', 'green', '/admin/posts', $post_counts));
                //$row->column(4, new InfoBox('回帖数量', 'book', 'yellow', '/admin/posts_comments', $post_comments));
                // $row->column(3, new InfoBox('Documents', 'file', 'red', '/admin/files', '698726'));
            });

            /*$content->row(function ($row) {
                $all_users = DB::table('users')->count();
                $row->column(5, new InfoBox('累计用户', 'users', 'red', '/admin/users', $all_users));
            });
            $content->row(function ($row) {
                $post_counts = DB::table('posts')->count();
                $row->column(5, new InfoBox('帖子数量', 'file', 'green', '/admin/posts', $post_counts));
            });*/
            $content->row(function ($row) {
                $project_count = DB::table('projects')->count();
                $row->column(5, new InfoBox('项目数', 'book', 'yellow', '/projects', $project_count));
            });

        });
    }
}
